﻿
/**
 * implementation of BFS: let fringe be a first-in-first-out (FIFO) queue
 */
public class BFS : IGenericGraphSearch
{
    /** fringe = FIFO queue */
    private System.Collections.Generic.Queue<Node> mFringe;

    /**
     * Constructor calls super constructor
     */
    public BFS(string fn) : base(fn)
    {
        mFringe = new System.Collections.Generic.Queue<Node>();
    }

    /**
     * insert a node to the fringe 
     */
    public override void generic_insertToFringe(Node n)
    {
        mFringe.Enqueue(n);
    }

    /**
     * test if fringy is empty
     */
    public override bool generic_isFringeEmpty()
    {
        return (mFringe.Count == 0);
    }

    /**
     * remove first element of fringe 
     */
    public override Node generic_removeFirst()
    {
        return mFringe.Dequeue();
    }


    /**
     * insert nodes into fringe 
     */
    public override void generic_insertAll(System.Collections.Generic.List<Node> nodes)
    {
        foreach (Node n in nodes) { mFringe.Enqueue(n); }
    }
    

} // class BFS